<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Extracts uploaded file embedded in the FDF</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fdf-get-ap.html">fdf_get_ap</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.fdf-get-encoding.html">fdf_get_encoding</a></div>
 <div class="up"><a href="ref.fdf.html">FDF 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.fdf-get-attachment" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">fdf_get_attachment</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">fdf_get_attachment</span> &mdash; <span class="dc-title">Extracts uploaded file embedded in the FDF</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.fdf-get-attachment-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>fdf_get_attachment</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$fdf_document</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldname</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$savepath</code></span>
   )</div>

  <p class="para rdfs-comment">
   Extracts a file uploaded by means of the &quot;file selection&quot; field
   <em><code class="parameter">fieldname</code></em> and stores it under
   <em><code class="parameter">savepath</code></em>. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.fdf-get-attachment-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">fdf_document</code></em></dt>

     <dd>

      <p class="para">
       The FDF document handle, returned by <span class="function"><a href="function.fdf-create.html" class="function">fdf_create()</a></span>,
       <span class="function"><a href="function.fdf-open.html" class="function">fdf_open()</a></span> or <span class="function"><a href="function.fdf-open-string.html" class="function">fdf_open_string()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">fieldname</code></em></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">savepath</code></em></dt>

     <dd>

      <p class="para">
       May be the name of a plain file or an existing directory in which the
       file is to be created under its original name. Any existing file under
       the same name will be overwritten.
      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        There seems to be no other way to find out the original filename but
        to store the file using a directory as 
        <em><code class="parameter">savepath</code></em> and check for the basename it was
        stored under.
       </p>
      </p></blockquote>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.fdf-get-attachment-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The returned array contains the following fields:
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara"><em><code class="parameter">path</code></em> - path were the file got stored</span>
    </li>
    <li class="listitem">
     <span class="simpara"><em><code class="parameter">size</code></em> - size of the stored file in bytes</span>
    </li>
    <li class="listitem">
     <span class="simpara"><em><code class="parameter">type</code></em> - mimetype if given in the FDF</span>
    </li>
   </ul>
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.fdf-get-attachment-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3391">
    <p><strong>Example #1 Storing an uploaded file</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$fdf&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_open_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$HTTP_FDF_DATA</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fdf_get_attachment</span><span style="color: #007700">(</span><span style="color: #0000BB">$fdf</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"filename"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"/tmpdir"</span><span style="color: #007700">);<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;uploaded&nbsp;file&nbsp;is&nbsp;stored&nbsp;in&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #0000BB">path</span><span style="color: #007700">]</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fdf-get-ap.html">fdf_get_ap</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.fdf-get-encoding.html">fdf_get_encoding</a></div>
 <div class="up"><a href="ref.fdf.html">FDF 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
